﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using StudentMgmt.DBUtility;

namespace StudentMgmt
{
    public partial class frmUserLogin : Form
    {
        public frmUserLogin()
        {
            InitializeComponent();
        }
        private readonly string connString = ConfigurationManager.ConnectionStrings["SQLProfileConnString"].ConnectionString;

     
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            string usrName = this.tbUserName.Text.Trim();
            string psd = this.tbPassword.Text.Trim();
            StringBuilder builder = new StringBuilder();
            builder.Append("select count(*) from Usr where UserId='"+usrName+"' and Psd ='"+psd+"'");
             int val =SqlHelper.RunSQLReturnValue(builder.ToString());
            if (val>0){               
                  frmMain objFrmMain = new frmMain();
                 this.Hide();
                 objFrmMain.Show();
            }
            else
            {
                MessageBox.Show("登录失败！");
            }
          
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            frmUserRegister objFrmUser = new frmUserRegister();
            this.Hide();
            objFrmUser.Show();
        }
    }
}
